package com.coreJava.testio.socket2;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

/**
 * 作者: LCG
 * 日期: 2020/2/16 22:27
 * 描述:
 */
public class SocketRunable implements Runnable {


    @Override
    public void run() {
        try{
            Socket socket=new Socket("192.168.137.1",9999);

            PrintWriter printWriter=new PrintWriter(socket.getOutputStream());

            printWriter.println(Thread.currentThread().getName()+"---client data---");

            printWriter.flush();


            InputStreamReader inputStreamReader=new InputStreamReader(socket.getInputStream());

            BufferedReader bufferedReader=new BufferedReader(inputStreamReader);
            System.out.println("==========等待返回数据==========");
            System.out.println("=====>"+bufferedReader.readLine());
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
